<script lang="ts" setup>
import { go,goCommunity } from "../../tools/go"
import UniIcons from "../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
import BHeader from "../../components/header/bHeader.vue";


interface NavItem {
  title: string;
  description: string;
  icon: string;
  color: string;
  path: string;
}

const navItems: NavItem[] = [
  {
    title: "路由管理",
    description: "配置和管理系统路由信息",
    icon: "compose",
    color: "#2979ff",
    path: "/manage/RouterManage",
  },
  {
    title: "API管理",
    description: "管理系统接口和服务配置",
    icon: "settings",
    color: "#ff9500",
    path: "/manage/ApiManage",
  },
  {
    title: "角色管理",
    description: "系统角色权限配置中心",
    icon: "staff",
    color: "#19be6b",
    path: "/manage/RoleManage",
  },
  {
    title: "用户管理",
    description: "管理系统用户信息配置",
    icon: "person",
    color: "#f56c6c",
    path: "/manage/UserRoleManage",
  },
  {
    title: "公告中心",
    description: "对公告增加删除",
    icon: "calendar",
    color: "#909399",
    path: "/manage/AnctManagement",
  }, {
    title: "帖子审核",
    description: "审核社区内的帖子信息",
    icon: "eye",
    color: "#e6a23c",
    path: "/manage/PostReview",
  }, {
    title: "ai助手",
    description: "目前只能聊天",
    icon: "eye",
    color: "#e6a23c",
    path: "/manage/AiManage",
  }
];

const handleNavClick = (item: NavItem) => {
  go(item.path)
};
</script>

<template>
  <view class="back">
    <view class="container">
      <!-- 顶部标题栏 -->
      <b-header :go="goCommunity"></b-header>

      <!-- 功能卡片网格区域 -->
      <scroll-view class="content" scroll-y>
        <view class="grid">
          <view
              v-for="(item, index) in navItems"
              :key="index"
              class="grid-item"
              @click="handleNavClick(item)"
          >
            <view class="card">
              <uni-icons
                  :type="item.icon"
                  size="32"
                  :color="item.color"
                  class="card-icon"
              />
              <text class="card-title">{{ item.title }}</text>
              <text class="card-desc">{{ item.description }}</text>
            </view>
          </view>
        </view>
      </scroll-view>
    </view>
  </view>
</template>


<style scoped lang="scss">
@use "../../static/css/main";

.back {
  @include main.useTheme() {
    .container {
      .content {
        .grid {
          .grid-item {
            .card {
              .card-title {
                font-size: 16px;
                font-weight: 500;
                color: main.getVal("two_lv_text_color");
                margin-bottom: 16rpx;
              }

              .card-desc {
                font-size: 12px;
                color: main.getVal("other_lv_text_color");
                text-align: center;
                line-height: 1.4;
              }
              .card-icon {
                margin-bottom: 20rpx;
                width: 32px;
                height: 32px;
                display: flex;
                justify-content: center;
                align-items: center;
              }
              padding: 40rpx;
              display: flex;
              flex-direction: column;
              align-items: center;
              height: 100%;
            }
            background-color: main.getVal("primary_bg_color");
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
            transition: all 0.3s ease;
          }
          display: grid;
          grid-template-columns: repeat(2, 1fr);
          gap: 30rpx;
          padding-bottom: 30rpx;
        }
        flex: 1;
        overflow: auto;
        padding: 30rpx;
      }


      min-height: 100vh;
      height: 100%;
      display: flex;
      flex-direction: column;
      background-color: main.getVal("two_lv_bg_color");
    }

    .grid-item:active {
      transform: scale(0.98);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
  }
}

</style>
